package com.example.demo.repository;

import com.example.demo.entity.Power;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PowerRepository extends CrudRepository<Power,Long> {

    @Query("SELECT p.subPower FROM Power p WHERE p.userID = :userID AND p.moduleID = :moduleID")
    String findUserIDAndModuleID(String userID, String moduleID);

    @Query("select p.moduleID,p.moduleName,p.subPower from Power p where p.userID = :userID")
    List<Object[]> findAllPower(String userID);

    @Query("select p.subPower from Power p where p.userID = :userID and p.moduleID = :moduleID")
    String findOnlyPower(String userID, String moduleID);
}
